// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var databind = require("databind");
	var css_detail_info = require("./clientManage_details.css");
	var html_auditState_Yes = require("../client/clientManage_auditStateYes.html");
	var html_auditState_No = require("../client/clientManage_auditStateNo.html");
	var html_activeCard = require("./html_activeCard.html");
	var html_adjustTemporary = require("./html_adjustTemporary.html");
	var tools = require("tools");
	var html_addFollowPerson = require("./html_addFollowPerson.html");
	var html_addCommission = require("./html_addCommission.html");
	var isCard;
	var html_startAndStopFinanceFollowPerson = require("./html_startAndStopFinanceFollowPerson.html");
	var html_updateShortName = require("./html_updateShortName.html");
	var tools = require("tools");
	var interestRate;
	var constant = require("constant");
	var penalInterest;
	
	var pageIndex = 1,
		pageSize = 20,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var enterpriseId = "";
	var businessLicenceImage = "";
	var certificateImage = "";
	var legalPersonFrontImage = "";
	var legalPersonBackImage = "";
	var qualificationsImage = "";
	var creditReportImage = "";
	var enterpriseCode;
	var init = function(page) {
		enterpriseId = page.params.enterpriseId || base.getUrlParam("enterpriseId");
		$(".nav_active").removeClass("nav_active1");
		$(".enterpriseInfo").addClass("nav_active1");
		initEvent();
		inquireEnterpriseDetail(enterpriseId);
		router.init();
	};
	var initEvent = function() {
		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			location.href = "../login/login.html";
		}
		
		//查看审批记录
		$("#clientManage_details .auditRecord").unbind("click").click(function(){
			window.open("../auditRecord/auditRecord.html?recordType=4&recordId=" + enterpriseId);
		});
		
		$("#clientManage_details").on("click", ".delete", function(){
			var $this = $(this);
			dialog.showConfirmDialog("删除质押率", "是否确认删除质押率？", function(){
				if ($this.parents("tr").attr("pledgerateid") == null) {
					$this.parents("tr").remove();
				} else {
					deleteFinanceBulkstockPledgeRate($this.parents("tr").attr("pledgerateid"), function(){
						$this.parents("tr").remove();
					});
				}
			});
		});
		
		$("#clientManage_details").on("change", ".cm_creditLine", function(){
			$(".cm_creditLine1").html(tools.formatCurrency($(".cm_creditLine").val()));
		});
		
		//新增货物质押率信息
		$("#clientManage_details .addBulkstockPledge").unbind("click").click(function(){
			var str = "<tr><td><input name='productName' /></td><td><select name='productType'><option value='2'>舱单质押</option><option value='3'>仓储质押</option><option value='1'>舱单代采</option><option value='5'>仓储代采</option><option value='4'>运费保理</option><option value='6'>代销</option></select></td><td><select isNUll='1' codeName='货物' name='bulkstockInfoIds'><select></td><td><input isNUll='1' codeName='质押率上限' name='pledgeRateCeilings' /></td><td><input isNUll='1' codeName='年化率下限' name='loanRateCeilings' /></td><td><input isNUll='1' codeName='保证金比例' name='bailRates' /></td><td><input isNUll='1' codeName='有效起始时间' name='effectiveStartDates' onfocus=\"WdatePicker({minDate:'%y-%M-%d'})\" /></td><td><input isNUll='1' codeName='有效截止时间' name='effectiveEndDates' onfocus=\"WdatePicker({minDate:'%y-%M-%d'})\" /></td><td><a href='javascript:void(0);' class='delete'>删除</a></td></tr>";
			$("#clientManage_details .bulkstockPledgeTable").append(str);
			tools.loadSelectList($("#clientManage_details .bulkstockPledgeTable tr:last").find("select[name=bulkstockInfoIds]"), "inquireBulkstockInfoPageList.json?activeState=true&pageSize=10000", "bulkstockInfoId", "bulkstockName" , "specificationName");
		});
		
		if ($("#clientManage_details .auditState1").val() == "true") {
			$("#clientManage_details .gradeInfo .addfile").remove();
			$("#clientManage_details .gradeInfo .removeFile").remove();
//			$("#clientManage_details .saveGrade").remove();
			$("#clientManage_details .saveGrade").hide();
			$("#clientManage_details .dialogBtn").remove();
			$("#clientManage_details .addBulkstockPledge").remove();
		}
		
		
		$("#clientManage_details").on("click", ".gradeInfo .removeFile", function() {
//			$(this).parents(".showFiles").prev().remove();
			$(this).parents(".showFiles").remove();
			var fs = [];
			$.each($('#clientManage_details .gradeInfo .mas'), function() {
				fs.push($(this).attr("fileUuid"));
			});
			$("#clientManage_details .gradeInfo .evaluationFileUuid").val(fs);
		});
		
		//保存等级信息
		$("#clientManage_details .saveGrade").unbind("click").click(function(){
			$("#clientManage_details").attr("action", "auditEnterpriseSave");
			$("#clientManage_details input[name=approvalBooks]").attr("isNull", "0");
			databind.submitDom($("#clientManage_details"), function(){
				base.alert("1", "保存成功!");
				router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
			});
		});
		
		//多级审核保存
		$("#clientManage_details .button-Save").unbind("click").click(function(){
			$(".multistageAudit").attr("action", "saveEnterpriseAudit");
			$(".multistageAudit").append("<input type='hidden' name='enterpriseId' value='"+ enterpriseId +"'/>");
			databind.submitDom($(this).parents(".multistageAudit"), function(){
				base.alert(1, "保存成功！");
				router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
			});
		});
		
		//多级审核提交
		$("#clientManage_details .button-Submit").unbind("click").click(function(){
			$(".multistageAudit").attr("action", "submitEnterpriseAudit");
			$(".multistageAudit").append("<input type='hidden' name='enterpriseId' value='"+ enterpriseId +"'/>");
			databind.submitDom($(this).parents(".multistageAudit"), function(){
				base.alert(1, "提交成功！");
				router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
			});
		});
		
		//开卡
		$(".activeCard").unbind("click").click(function(){
			$("#popdialog").html(html_activeCard);
			$("#activeCard_dialog input[name=enterpriseId]").val(enterpriseId);
			
			$("#activeCard_dialog .dialogTitle").html("开卡");
			
			$("#activeCard_dialog").on("change", "#cardFrontFile", function(){
				tools.uploadFile("cardFrontFile", function(data){
					$("label[for=cardFrontFile]").html(data.data[0].fileName);
					$(".cardFrontFile").val(data.data[0].fileUuid);
				});
			});
			
			$("#activeCard_dialog").on("change", "#cardBackFile", function(){
				tools.uploadFile("cardBackFile", function(data){
					$("label[for=cardBackFile]").html(data.data[0].fileName);
					$(".cardBackFile").val(data.data[0].fileUuid);
				});
			});
			
			dialog.showDialog($("#activeCard_dialog"));
			
			$("#activeCard_dialog .dialogHandlerBtn").unbind("click").click(function(){
				databind.submitDom($("#activeCard_dialog .dialogContent"), function(){
					base.alert(1, "提交成功！");
					dialog.hideDialog($("#activeCard_dialog"));
					router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
				});
			});
		});
		
		tools.fileupload($("#clientManageAuditFile1"), null, function(data){
			var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.result.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.result.data[0].fileUuid + '" class="showProductIntro">' + data.result.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
			$("#clientManage_details .gradeInfo .addfile").before(str);
			var fs = [];
			$.each($('#clientManage_details .gradeInfo .mas'), function() {
				fs.push($(this).attr("fileUuid"));
			});
			$("#clientManage_details .gradeInfo .evaluationFileUuid").val(fs);
		});
		
		$(".button_cancel").on("mouseenter", function() {
			$(".auditState").css("display", "inline-block");
			$(".auditStateNo").css("color", "#000000");
			$(".auditStateYes").css("color", "#000000");
		});

		$(".auditState").on("mouseleave", function() {
			$(".auditState").css("display", "none");
		});

		$(".auditStateYes").on("mouseenter", function() {
			$(".auditStateYes").css("color", "blue");
		});

		$(".auditStateYes").on("mouseleave", function() {
			$(".auditStateYes").css("color", "#000000");
		});
		$(".auditStateNo").on("mouseenter", function() {
			$(".auditStateNo").css("color", "blue");
		});

		$(".auditStateNo").on("mouseleave", function() {
			$(".auditStateNo").css("color", "#000000");
		});

		//修改企业简称
		$("#clientManage_details .updateShortName").unbind("click").click(function(){
			$("#popdialog").html(html_updateShortName);
			dialog.showDialog($("#dialog_updateShortName"));
			$("#dialog_updateShortName input[name=enterpriseId]").val(enterpriseId);
			$("#dialog_updateShortName .dialogHandlerBtn").unbind("click").click(function(){
				databind.submitDom($("#dialog_updateShortName"), function(){
					base.alert(1, "修改成功！");
					dialog.hideDialog($("#dialog_updateShortName"));
					router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
				});
			});
		});
		
		//调整临时额度
		$(".adjustTemporary").unbind("click").click(function(){
			$("#popdialog").html(html_adjustTemporary);
			databind.fillForm($("#temporary_dialog"), {
				enterpriseId: enterpriseId
			});
			
			tools.clearNoNum($("#temporary_dialog input[name=temporaryCreditline]"));
			
			$("#temporary_dialog").on("change", "#adjustTemporaryFile", function() {
//				uploadFile($("#clientManageAuditFile"), $("#temporary_dialog .addfile"), $(".evaluationFileUuid"), "clientManageAuditFile");
				tools.uploadFile("adjustTemporaryFile", function(data){
					var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.data[0].fileUuid + '" class="showProductIntro">' + data.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
					$("#temporary_dialog .addfile").before(str);
					var fs = [];
					$.each($('#temporary_dialog .mas'), function() {
						fs.push($(this).attr("fileUuid"));
					});
					$("#temporary_dialog .evaluationFileUuid").val(fs);
				});
			});
			
			$(".footerBtn").on("click", "#sure", function() {
				databind.submitDom($("#temporary_dialog"), function() {
					base.alert(1, "资信等级调整成功！");
					dialog.hideDialog($("#temporary_dialog"));
				});
			});
			
			$("#temporary_dialog").on("click", ".removeFile", function() {
				$(this).parents(".showFiles").prev().remove();
				$(this).parents(".showFiles").remove();
				var fs = [];
				$.each($('#temporary_dialog .mas'), function() {
					fs.push($(this).attr("fileUuid"));
				});
				$("#temporary_dialog .evaluationFileUuid").val(fs);
			});
			
			dialog.showDialog($("#temporary_dialog"));
		});

		//点击企业基本信息
		$(".clientManage_details1 .enterpriseInfo").on("click", function() {
			router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId, true);
		});

		$(".financeSituation").on("click", function() {
			router.route("client/clientManage_financeSituation.html?enterpriseId=" + enterpriseId);
		});

		//证明材料
		$(".financeEvidentiary").on("click", function() {
			router.route("client/clientManage_financeEvidentiary.html?enterpriseId=" + enterpriseId);
		});

		//我的客户
		$(".financeBelongs").on("click", function() {
			router.route("client/clientManage_belongs.html?enterpriseId=" + enterpriseId);
		});
		
		//工商信息
		$(".portraitInfo").on("click", function() {
			window.open("../businessInfo/index1.html?enterpriseId=" + enterpriseId);
		});
		
		//监控中心
		$(".toAllMapMonitor").on("click", function() {
			window.open("http://222.79.247.164:9090/saas/report/toAllMapMonitor?enterpriseId=" + enterpriseId);
		});
		
		//实名认证
		$(".authenticationState").on("click", function() {
			router.route("client/clientManage_authentication.html?enterpriseId=" + enterpriseId);
		});
	
		//新增跟进人
		$("#clientManage_details .addFollowPerson").unbind("click").click(function(){
			$("#popdialog").html(html_addFollowPerson);
			$("#dialog_createFinanceFollowPerson input[name=enterpriseId]").val(enterpriseId);
			$("#dialog_createFinanceFollowPerson input[name=clientNumber]").val(enterpriseCode);
			tools.loadSelectList($("#dialog_createFinanceFollowPerson select[name=employeeId]"), "inquireEmployeeList.json?subOrg=0", "employeeId", "name");
			dialog.showDialog($("#dialog_createFinanceFollowPerson"));
			$("#dialog_createFinanceFollowPerson .dialogHandlerBtn").unbind("click").click(function(){
				databind.submitDom($("#dialog_createFinanceFollowPerson"), function(){
					base.alert(1, "添加成功！");
					dialog.hideDialog($("#dialog_createFinanceFollowPerson"));
					router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
				});
			});
		});
		
		//新增佣金比例分配
		$("#clientManage_details .addCommissionTable").unbind("click").click(function(){
			var ii = layer.open({
        	  area: ['420px', '440px'], //宽高
			  title: "新增佣金比例分配信息",
			  type: 1,
			  skin: 'layui-layer-demo', //样式类名
			  closeBtn: 1, //不显示关闭按钮
			  anim: 2,
			  shadeClose: true, //开启遮罩开启
			  content: html_addCommission,
			  btn: ['确定', '取消'],
			  yes: function(){
			  	databind.submitDom($("#dialog_createCommission"), function(){
					layer.msg("添加成功");
			  		layer.close(ii);
			  		router.route("client/clientManage_details.html?enterpriseId="+enterpriseId);
				});
			  }
			});
			
			$("#dialog_createCommission input[name=enterpriseId]").val(enterpriseId);
			
			tools.fileupload($("#commissionFile"), null, function(data){
				var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.result.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.result.data[0].fileUuid + '" class="showProductIntro">' + data.result.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
				$("#dialog_createCommission .addfile").before(str);
				var fs = [];
				$.each($('#dialog_createCommission .mas'), function() {
					fs.push($(this).attr("fileUuid"));
				});
				$("#dialog_createCommission input[name=fileUuids]").val(fs);
			});
			
			$("#dialog_createCommission").on("click", ".removeFile", function() {
				$(this).parents(".showFiles").remove();
				var fs = [];
				$.each($('#dialog_createCommission .mas'), function() {
					fs.push($(this).attr("fileUuid"));
				});
				$("#dialog_createCommission input[name=fileUuids]").val(fs);
			});
			
			//加载下拉框
			base.fnAjax({
				action: "inquireAssociatedPersonList.json",
				async: false,
				oData: {
					enterpriseId: enterpriseId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						$.each(data.datas, function(i, v) {
							$("#dialog_createCommission select[name=name]").append('<option accountId="'+ this.accountId +'" personType="'+ this.personType +'" value="' + this.name + '">' + this.name + '('+this.personType+')</option>');
						});
						$("#dialog_createCommission input[name=accountId]").val($("#dialog_createCommission select[name=name]").find('option:selected').attr('accountId'));
						$("#dialog_createCommission input[name=personType]").val($("#dialog_createCommission select[name=name]").find('option:selected').attr('personType'));
					} else {
						base.alert(2, "信息获取失败");
					}
				}
			});
			
			$("#dialog_createCommission").on("change", "select[name=name]", function() {
				$("#dialog_createCommission input[name=accountId]").val($(this).find('option:selected').attr('accountId'));
				$("#dialog_createCommission input[name=personType]").val($(this).find('option:selected').attr('personType'));
			});
		});
		
		//额度信贷批复书签章
		$("#clientManage_details").on("change", "#clientManageAuditFile2", function() {
			tools.uploadFile("clientManageAuditFile2", function(data){
				var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.data[0].fileUuid + '" class="showProductIntro">' + data.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
				$("#clientManage_details .multistageAudit4 .addfile").before(str);
				var fs = [];
				$.each($('#clientManage_details .multistageAudit4 .mas'), function() {
					fs.push($(this).attr("fileUuid"));
				});
				$("#clientManage_details .multistageAudit4 .evaluationFileUuid").val(fs);
			});
		});
		
		$("#clientManage_details .multistageAudit4").on("click", ".removeFile", function() {
			$(this).parents(".showFiles").remove();
			var fs = [];
			$.each($('#clientManage_details .multistageAudit4 .mas'), function() {
				fs.push($(this).attr("fileUuid"));
			});
			$("#clientManage_details .multistageAudit4 .evaluationFileUuid").val(fs);
		});
		
		//e签宝实名认证
        $("#clientManage_details .authentication_btn").unbind("click").click(function(){
        	router.route("client/clientAuthentication.html?enterpriseId=" + enterpriseId);
        });
		
		tools.clearNoNum($("input[name=creditLine]"));
	};

	var loadMemberGradePageList = function() {
		base.fnAjax({
			action: "inquireMemberGradePageList.json",
			version: "v1.0",
			async: false,
			oData: {}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $(".qualificationsTpl").html();
					var html = juicer(tpl, data);
					$(".client_gradeName").html(html);
					$(".memberGradeId").val($(".client_gradeName option:selected").attr("memberGradeId"));
					databind.fillForm($("#clientManage_details .gradeInfo"), data.datas[0]);
				} else {
					base.alert(3, data.message);
				}
			}
		});

		$(".client_gradeName").change(function() {
			var gradeName = $(".client_gradeName").val();

			base.fnAjax({
				action: "inquireMemberGradeByGradeName.json",
				version: "v1.0",
				async: false,
				oData: {
					gradeName: gradeName
				}, //传递参数
				fnSuccess: function(data) { //成功回调
					if (data.status == 200) {
						var memberGrade = data.datas[0];
						$(".cm_creditLine").val(memberGrade.creditLine);
						$(".memberGradeId").val($(".client_gradeName option:selected").attr("memberGradeId"));
						databind.fillForm($(".gradeInfo"), data.datas[0]);
						if (isCard) {
							$("input[name=interestRate]").val(interestRate);
							$("input[name=penalInterest]").val(penalInterest);
							$("input[name=interestRate]").attr("readonly", "readonly");
							$("input[name=penalInterest]").attr("readonly", "readonly");
						}
						$(".cm_creditLine1").html(tools.formatCurrency($(".cm_creditLine").val()));
					} else {
						base.alert(3, data.message);
					}
				}
			});
		});
	};
	
	var inquireExistEnterpriseGradeEvaluation = function(enterpriseId, data1) {
		base.fnAjax({
			action: "inquireExistEnterpriseGradeEvaluation.json",
			version: "v1.0",
			async: false,
			oData: {
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					if (data.datas[0].isExist == true) {
						base.alert(3, "该客户尚有未完成审批的等级调整！");
					} else {
						$("#popdialog").html(html_auditState_Yes);
						
						$("#auditState_clientManage_dialog .dialogTitle").html("调整资信等级");
						$("#auditState_clientManage_dialog").attr("action", "adjustEnterpriseGrade");
						var delete_clientManage_dialog = $("#auditState_clientManage_dialog");
						dialog.showDialog(delete_clientManage_dialog, function() {});
						
						tools.clearNoNum($("#cm_creditLine"));
						
						loadMemberGradePageList1();
						var d = new Date();
						var dd = d.getFullYear() + "-" + (d.getMonth() * 1 + 1 * 1) + "-" + d.getDate();
						$("#effectiveStartDate").val(dd);
						databind.fillForm($("#auditState_clientManage_dialog"), {
							enterpriseId: enterpriseId
						});
						
						if (isCard) {
							$("input[name=interestRate]").val(interestRate);
							$("input[name=penalInterest]").val(penalInterest);
							$("input[name=interestRate]").attr("readonly", "readonly");
							$("input[name=penalInterest]").attr("readonly", "readonly");
						}
			
						$("#auditState_clientManage_dialog").on("change", "#clientManageAuditFile", function() {
							uploadFile($("#clientManageAuditFile"), $("#auditState_clientManage_dialog .addfile"), $(".evaluationFileUuid"), "clientManageAuditFile");
						});
						
						//新增货物质押率信息
						$("#auditState_clientManage_dialog .addBulkstockPledge").unbind("click").click(function(){
							var str = "<tr><td><input name='productName' /></td><td><select name='productType'><option value='2'>舱单质押</option><option value='3'>仓储质押</option><option value='1'>舱单代采</option><option value='5'>仓储代采</option><option value='4'>运费保理</option><option value='6'>代销</option></select></td><td><select isNUll='1' codeName='货物' name='bulkstockInfoIds'><select></td><td><input isNUll='1' codeName='质押率上限' name='pledgeRateCeilings' /></td><td><input isNUll='1' codeName='年化率下限' name='loanRateCeilings' /></td><td><input isNUll='1' codeName='保证金比例' name='bailRates' /></td><td><input isNUll='1' codeName='有效起始时间' name='effectiveStartDates' onfocus=\"WdatePicker({minDate:'%y-%M-%d'})\" /></td><td><input isNUll='1' codeName='有效截止时间' name='effectiveEndDates' onfocus=\"WdatePicker({minDate:'%y-%M-%d'})\" /></td><td><a href='javascript:void(0);' class='delete1'>删除</a></td></tr>";
							$("#auditState_clientManage_dialog .bulkstockPledgeTable").append(str);
							tools.loadSelectList($("#auditState_clientManage_dialog .bulkstockPledgeTable tr:last").find("select[name=bulkstockInfoIds]"), "inquireBulkstockInfoPageList.json?activeState=true&pageSize=10000", "bulkstockInfoId", "bulkstockName" , "specificationName");
						});
						
						//删除货物质押率信息
						$("#auditState_clientManage_dialog").on("click", ".delete1", function(){
							$(this).parents("tr").remove();
						});
			
						$("#auditState_clientManage_dialog").on("click", ".removeFile", function() {
	//							$(this).parents(".showFiles").prev().remove();
							$(this).parents(".showFiles").remove();
							var fs = [];
							$.each($('#auditState_clientManage_dialog .mas'), function() {
								fs.push($(this).attr("fileUuid"));
							});
							$("#auditState_clientManage_dialog .evaluationFileUuid").val(fs);
						});
			
						$(".footerBtn").on("click", "#sure", function() {
							databind.submitDom($("#auditState_clientManage_dialog"), function() {
								base.alert(1, "资信等级调整成功！");
								dialog.hideDialog($("#auditState_clientManage_dialog"));
							});
						});
						
						if(data1.datas[0].enterpriseGradeEvaluationDetail != null) {
							databind.fillForm($("#auditState_clientManage_dialog"), data1.datas[0].enterpriseGradeDetail);
							$("#auditState_clientManage_dialog input[name=evaluationFileUuid]").val(data1.datas[0].enterpriseGradeEvaluationDetail.evaluationFileUuid);
							$.each((data1.datas[0].enterpriseGradeEvaluationDetail.evaluationFileUuid).split(','), function() {
								var _this = this;
								if ($.trim(_this) != "") {
									var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + _this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + _this + '" class="showProductIntro">' + tools.inquireFile(_this) + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
									$("#auditState_clientManage_dialog .addfile").before(str);
								}
							});
						
							$("#auditState_clientManage_dialog .bulkstockPledgeTable").html($("#clientManage_details .bulkstockPledgeTable").html());
							$.each($("#auditState_clientManage_dialog .bulkstockPledgeTable tr"), function(){
								var str = '<a href="javascript:void(0);" class="delete">删除</a>';
								$(this).find("td:last").html(str);
							});
							
							$("#auditState_clientManage_dialog").on("click", ".delete", function(){
								var $this = $(this);
								dialog.showConfirmDialog("删除质押率", "是否确认删除质押率？", function(){
									if ($this.parents("tr").attr("pledgerateid") == null) {
										$this.parents("tr").remove();
									} else {
										deleteFinanceBulkstockPledgeRate($this.parents("tr").attr("pledgerateid"), function(){
											$this.parents("tr").remove();
										});
									}
								});
							});
						}
					}
					
				} else {
					base.alert(3, data.message);
				}
			}
		});
	};
	
	var loadMemberGradePageList1 = function() {
		base.fnAjax({
			action: "inquireMemberGradePageList.json",
			version: "v1.0",
			async: false,
			oData: {}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#auditState_clientManage_dialog #qualificationsTpl").html();
					var html = juicer(tpl, data);
					$("#auditState_clientManage_dialog #client_gradeName").html(html);
					$("#auditState_clientManage_dialog #memberGradeId").val($("#auditState_clientManage_dialog #client_gradeName option:selected").attr("memberGradeId"));
					databind.fillForm($("#auditState_clientManage_dialog"), data.datas[0]);
				} else {
					base.alert(3, data.message);
				}
			}
		});

		$("#auditState_clientManage_dialog #client_gradeName").change(function() {

			var gradeName = $("#auditState_clientManage_dialog #client_gradeName").val();

			base.fnAjax({
				action: "inquireMemberGradeByGradeName.json",
				version: "v1.0",
				async: false,
				oData: {
					gradeName: gradeName
				}, //传递参数
				fnSuccess: function(data) { //成功回调
					if (data.status == 200) {
						var memberGrade = data.datas[0];
						$("#auditState_clientManage_dialog #cm_creditLine").val(memberGrade.creditLine);
						$("#auditState_clientManage_dialog #memberGradeId").val($("#auditState_clientManage_dialog #client_gradeName option:selected").attr("memberGradeId"));
						databind.fillForm($("#auditState_clientManage_dialog #auditState_clientManage_dialog"), data.datas[0]);
						if (isCard) {
							$("#auditState_clientManage_dialog input[name=interestRate]").val(interestRate);
							$("#auditState_clientManage_dialog input[name=penalInterest]").val(penalInterest);
							$("#auditState_clientManage_dialog input[name=interestRate]").attr("readonly", "readonly");
							$("#auditState_clientManage_dialog input[name=penalInterest]").attr("readonly", "readonly");
						}
					} else {
						base.alert(3, data.message);
					}
				}
			});
		});
	};

	//上传文件
	var uploadFile = function(dom, labelDom, valueDom, fileElementId) {
		if ($(dom).val() != "") {
			$.ajaxFileUpload({
				url: "/finance/api/v1.0/uploadFile.json", //你处理上传文件的服务端
				secureuri: false,
				fileElementId: fileElementId,
				dataType: 'json',
				success: function(data) {
					var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + data.data[0].fileUuid + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + data.data[0].fileUuid + '" class="showProductIntro">' + data.data[0].fileName + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
					$(labelDom).before(str);
					var fs = [];
					$.each($('#auditState_clientManage_dialog .mas'), function() {
						fs.push($(this).attr("fileUuid"));
					});
					$(valueDom).val(fs);
				},
				complete: function(xml) {
					$(dom).change(function() {
						uploadFile(dom, labelDom, valueDom, fileElementId);
					});
				},
				error: function(data, status, e) {
					if (data.msg == null) {
						base.alert(2, "文件太大无法上传");
					} else {
						base.alert(2, data.msg);
					}
				}
			});
		} else {
			base.alert(3, "请选择文件！");
		}
	};

	var auditEnterpriseConsent = function(enterpriseId) {
		$("#enterpriseId").val(enterpriseId);
		$(".footerBtn").on("click", "#sure", function() {
			databind.submitDom($(".dialogContent"), function() {
				base.alert(1, "企业认证通过！");
				location.href = "../client/clientManage.html";
			});
		});
	}

	var auditEnterpriseOppose = function(enterpriseId) {
		$(".footerBtn").on("click", "#sure_no", function() {
			var auditRemark = $("#auditRemark").val();
			base.fnAjax({
				action: "auditEnterpriseOppose.json",
				oData: {
					enterpriseId: enterpriseId,
					auditRemark: auditRemark
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						location.href = "../client/clientManage.html";
					} else {
						base.alert(2, "信息获取失败");
					}
				}
			});
		});
	};
	
	var deleteFinanceBulkstockPledgeRate = function(pledgeRateId, callback) {
		base.fnAjax({
			action: "deleteFinanceBulkstockPledgeRate.json",
			oData: {
				pledgeRateId: pledgeRateId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					base.alert(1, "删除成功！");
					callback();
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};
	
	//删除比例分配信息
	var deleteCommissionScaleTable = function(scaleId) {
		base.fnAjax({
			action: "deleteCommissionScaleTable.json",
			oData: {
				scaleId: scaleId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					layer.msg("删除成功!");
					router.route("client/clientManage_details.html?enterpriseId="+enterpriseId);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};
	
	//启用/停用比例分配信息
	var enableCommissionScaleTable = function(scaleId) {
		base.fnAjax({
			action: "enableCommissionScaleTable.json",
			oData: {
				scaleId: scaleId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					layer.msg("操作成功!");
					router.route("client/clientManage_details.html?enterpriseId="+enterpriseId);
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};
	
	//查询企业详细信息
	var inquireEnterpriseDetail = function(enterpriseId) {
		base.fnAjax({
			action: "inquireEnterpriseDetail.json",
			oData: {
				enterpriseId: enterpriseId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					
					var startTime  = new Date(Date.parse(data.datas[0].auditDate1));
					var endTime  = new Date(Date.parse("2017-09-25 00:00"));
					if (startTime <= endTime) {
						data.datas[0].auditSubmitState12 = true;
						$("#clientManage_details .multistageAudit12").hide();
					}
					 
					juicer.register("getValueByKey", constant.getValueByKey);
					
					if (data.datas[0].enterpriseGradeDetail == null) {
						$("#clientManage_details .button-submit").remove();
					}
					
					if(data.datas[0].authentication != 0 && data.datas[0].authentication != 4) {//未认证0 或 认证失败4 显示认证按钮
						 $("#clientManage_details .authentication_btn").remove();
					}
					
					enterpriseCode = data.datas[0].enterpriseCode;
					loadMemberGradePageList();
					if (data.datas[0].enterpriseGradeEvaluationDetail != null) {
						data.datas[0].enterpriseGradeEvaluationDetail.approveType = data.datas[0].approveType;
						databind.fillForm($("#clientManage_details"), data.datas[0].enterpriseGradeEvaluationDetail);
					}
					
					var enterpriseInfo = data.datas[0];
					$("#temporaryCreditline").text(tools.formatCurrency(data.datas[0].temporaryCreditlineDetail.temporaryCreditline/10000));
					if (data.datas[0].enterpriseShortName == null || data.datas[0].enterpriseShortName == "") {
						$("#clientManage_details .enterpriseShortName").text("无");
					} else {
						$("#clientManage_details .enterpriseShortName").text(data.datas[0].enterpriseShortName);
					}
					$("#enterpriseName").text(enterpriseInfo.enterpriseName);
					$("#qualifications").text(enterpriseInfo.qualifications);
					$("#businessLicence").text(enterpriseInfo.businessLicence);
					$("#gradeName").html(enterpriseInfo.gradeName);
					$("#creditLine").text(tools.formatCurrency(enterpriseInfo.creditLine/10000));
					$("#address").text(enterpriseInfo.address);
//					$("#nature").text(enterpriseInfo.nature);
					$("#nature").text(constant.getValueByKey(79, enterpriseInfo.unitTypeId));
					$("#contactAddress").text(enterpriseInfo.contactAddress);
					if (enterpriseInfo.businessTimeLimit == 0) {
						$("#businessTimeLimit").text("长期");
					}
					$("#businessScope").text(enterpriseInfo.businessScope);
					$("#registeredCapital").text(tools.formatCurrency(enterpriseInfo.registeredCapital/10000));
					$("#legalPerson").text(enterpriseInfo.legalPerson);
					$("#legalIdcard").text(enterpriseInfo.legalIdcard);
					$("#legalPeriod").text(enterpriseInfo.legalPeriod);
					$("#depositBank").text(enterpriseInfo.depositBank);
					$("#accountHolder").text(enterpriseInfo.accountHolder);
					$("#creditCard").text(enterpriseInfo.creditCard);
					businessLicenceImage = enterpriseInfo.businessLicenceImage;
					certificateImage = enterpriseInfo.certificateImage;
					legalPersonFrontImage = enterpriseInfo.legalPersonFrontImage;
					legalPersonBackImage = enterpriseInfo.legalPersonBackImage;
					qualificationsImage = enterpriseInfo.qualificationsImage;
					creditReportImage = enterpriseInfo.creditReportImage;
	 				isCard = data.datas[0].isCard;
					interestRate = data.datas[0].interestRate;
					penalInterest = data.datas[0].penalInterest;

					$(".button_cancel").css("display", "inline-block");
					if (enterpriseInfo.auditState != 1 && !enterpriseInfo.submitState) {
						$(".auditStateYes").addClass("none");
						$(".auditStateNo").addClass("none");
					}
					
					if(data.datas[0].enterpriseGradeEvaluationDetail != null) {
						$.each((data.datas[0].enterpriseGradeEvaluationDetail.evaluationFileUuid).split(','), function() {
							var _this = this;
							if ($.trim(_this) != "") {
								var str = '<span class="showFiles"><a target="_blank" class="mas" fileUuid="' + _this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + _this + '" class="showProductIntro">' + tools.inquireFile(_this) + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></span>';
								$("#clientManage_details .gradeInfo .addfile").before(str);
							}
						});
						
						$.each((data.datas[0].enterpriseGradeEvaluationDetail.approvalBooks).split(','), function() {
							var _this = this;
							if ($.trim(_this) != "") {
								var str = '<div class="showFiles"><a target="_blank" class="mas showloanIntro" id="' + _this + '" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + _this + '">' + tools.inquireFile(_this) + '</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="removeFile">x</a></div>';
								$("#clientManage_details .multistageAudit4 .addfile").before(str);
							}	
						});
					}
					
					databind.fillForm($("#clientManage_details"), data.datas[0]);
					
					if (data.datas[0].enterpriseGradeEvaluationDetail != null && data.datas[0].auditState != 1 && data.datas[0].enterpriseGradeEvaluationDetail.auditDate1 != "") {
						databind.fillForm($("#clientManage_details .multistageAudit"), data.datas[0].enterpriseGradeEvaluationDetail);
						$(".auditState1").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState1 + "");
						$(".audit1").val(data.datas[0].enterpriseGradeEvaluationDetail.audit1);
						
						$(".auditState2").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState2 + "");
						$(".audit2").val(data.datas[0].enterpriseGradeEvaluationDetail.audit2);
						
						$(".auditState3").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState3 + "");
						$(".audit3").val(data.datas[0].enterpriseGradeEvaluationDetail.audit3);
						
						$(".auditState4").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState4 + "");
						$(".audit4").val(data.datas[0].enterpriseGradeEvaluationDetail.audit4);
						
						$(".auditState5").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState5 + "");
						$(".audit5").val(data.datas[0].enterpriseGradeEvaluationDetail.audit5);
						
						$(".auditState6").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState6 + "");
						$(".audit6").val(data.datas[0].enterpriseGradeEvaluationDetail.audit6);
						
						$(".auditState7").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState7 + "");
						$(".audit7").val(data.datas[0].enterpriseGradeEvaluationDetail.audit7);
						
						$(".auditState8").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState8 + "");
						$(".audit8").val(data.datas[0].enterpriseGradeEvaluationDetail.audit8);
						
						$(".auditState9").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState9 + "");
						$(".audit9").val(data.datas[0].enterpriseGradeEvaluationDetail.audit9);
						
						$(".auditState10").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState10 + "");
						$(".audit10").val(data.datas[0].enterpriseGradeEvaluationDetail.audit10);
						
						$(".auditState11").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState11 + "");
						$(".audit11").val(data.datas[0].enterpriseGradeEvaluationDetail.audit11);
						
						$(".auditState12").val(data.datas[0].enterpriseGradeEvaluationDetail.auditState12 + "");
						$(".audit12").val(data.datas[0].enterpriseGradeEvaluationDetail.audit12);
					} else {
						databind.fillForm($("#clientManage_details .multistageAudit"), data.datas[0]);
						$(".auditState1").val(data.datas[0].auditState1 + "");
						$(".audit1").val(data.datas[0].audit1);
						
						$(".auditState2").val(data.datas[0].auditState2 + "");
						$(".audit2").val(data.datas[0].audit2);
						
						$(".auditState3").val(data.datas[0].auditState3 + "");
						$(".audit3").val(data.datas[0].audit3);
						
						$(".auditState4").val(data.datas[0].auditState4 + "");
						$(".audit4").val(data.datas[0].audit4);
						
						$(".auditState5").val(data.datas[0].auditState5 + "");
						$(".audit5").val(data.datas[0].audit5);
						
						$(".auditState6").val(data.datas[0].auditState6 + "");
						$(".audit6").val(data.datas[0].audit6);
						
						$(".auditState7").val(data.datas[0].auditState7 + "");
						$(".audit7").val(data.datas[0].audit7);
						
						$(".auditState8").val(data.datas[0].auditState8 + "");
						$(".audit8").val(data.datas[0].audit8);
						
						$(".auditState9").val(data.datas[0].auditState9 + "");
						$(".audit9").val(data.datas[0].audit9);
						
						$(".auditState10").val(data.datas[0].auditState10 + "");
						$(".audit10").val(data.datas[0].audit10);
						
						$(".auditState11").val(data.datas[0].auditState11 + "");
						$(".audit11").val(data.datas[0].audit11);
						
						$(".auditState12").val(data.datas[0].auditState12 + "");
						$(".audit12").val(data.datas[0].audit12);
					}
					
					
					$.each($(".multistageAudit .data"), function() {
						var $this = $(this);
						if ($.trim($this.html()) == "") {
							$this.parent().remove();
						}
					});
					
					$.each($("#clientManage_details .submitState"), function() {
						var $this = $(this);
						if ($this.val() == "true") {
							$this.parent().find(".auditInfo").after("<span style='color:red; margin-left: 15px;'>已提交</span>");
						} else {
							$this.parent().find(".auditInfo").after("<span style='color:red; margin-left: 15px;'>待提交</span>");
						}
					});
					
					if(data.datas[0].auditState != 2 && data.datas[0].auditState != 4) {
						$("#clientManage_details .adjustTemporary").remove();
						$("#clientManage_details .adjustGrade").remove();
						$("#clientManage_details .adjustGradeRecord").remove();
						$("#clientManage_details .button_cancel").remove();
						$("#clientManage_details .updateShortName").remove();
					}
					
					var tpl = $("#clientManage_details .followPersonTpl").html();
					var html = juicer(tpl, data);
					$("#clientManage_details .followPersonTable").html(html);
					
					var tpl2 = $("#clientManage_details .commissionTpl").html();
					var html2 = juicer(tpl2, data);
					$("#clientManage_details .commissionTable").html(html2);
					
					var tpl1 = $("#clientManage_details .bulkstockPledgeTpl").html();
					var html1 = juicer(tpl1, data);
					$("#clientManage_details .bulkstockPledgeTable").append(html1);
					
					//跟进人禁用
					$("#clientManage_details .disable").unbind("click").click(function(){
						$("#popdialog").html(html_startAndStopFinanceFollowPerson);
						$("#dialog_startAndStopFinanceFollowPerson .dialogTitle").html("禁用跟进人");
						$("#dialog_startAndStopFinanceFollowPerson input[name=followId]").val($(this).parents("tr").attr("followId"));
						dialog.showDialog($("#dialog_startAndStopFinanceFollowPerson"));
						
						$("#dialog_startAndStopFinanceFollowPerson .dialogHandlerBtn").unbind("click").click(function(){
							databind.submitDom($("#dialog_startAndStopFinanceFollowPerson"), function(){
								base.alert(1, "禁用成功！");
								dialog.hideDialog($("#dialog_startAndStopFinanceFollowPerson"));
								router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
							});
						});
					});
					
					//跟进人启用
					$("#clientManage_details .enable").unbind("click").click(function(){
						$("#popdialog").html(html_startAndStopFinanceFollowPerson);
						$("#dialog_startAndStopFinanceFollowPerson .dialogTitle").html("启用跟进人");
						$("#dialog_startAndStopFinanceFollowPerson input[name=followId]").val($(this).parents("tr").attr("followId"));
						dialog.showDialog($("#dialog_startAndStopFinanceFollowPerson"));
						
						$("#dialog_startAndStopFinanceFollowPerson .dialogHandlerBtn").unbind("click").click(function(){
							databind.submitDom($("#dialog_startAndStopFinanceFollowPerson"), function(){
								dialog.hideDialog($("#dialog_startAndStopFinanceFollowPerson"));
								base.alert(1, "启用成功！");
								router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId);
							});
						});
					});
					
					if (data.datas[0].auditState == 4 || data.datas[0].auditState == 0 || data.datas[0].auditState == 3) {
						databind.disableInput($("#clientManage_details"));
						$("#clientManage_details .gradeInfo .addfile").remove();
						$("#clientManage_details .gradeInfo .removeFile").remove();
						$("#clientManage_details .button-submit").remove();
//						$("#clientManage_details .saveGrade").remove();
						$("#clientManage_details .saveGrade").hide();
						$("#clientManage_details .dialogBtn").remove();
						$("#clientManage_details .addBulkstockPledge").remove();
					}
					
					$(".cm_creditLine1").html(tools.formatCurrency($(".cm_creditLine").val()));
					
					if (data.datas[0].auditSubmitState1 != false) {
						$("#clientManage_details .gradeInfo .addfile").hide();
						$("#clientManage_details .gradeInfo .removeFile").hide();
//						$("#clientManage_details .saveGrade").remove();
						$("#clientManage_details .saveGrade").hide();
						$("#clientManage_details .addBulkstockPledge").hide();
						$("#clientManage_details .delete").hide();
						databind.disableInput($("#clientManage_details .gradeInfo"));
					} else {
						databind.enableInput($("#clientManage_details .gradeInfo"));
					}
					
					if (!(data.datas[0].auditSubmitState2 == false && data.datas[0].auditSubmitState8 == true)) {
//						$("#clientManage_details .gradeInfo .addfile").hide();
//						$("#clientManage_details .gradeInfo .removeFile").hide();
//						$("#clientManage_details .saveGrade").hide();
//						$("#clientManage_details .addBulkstockPledge").hide();
//						$("#clientManage_details .delete").hide();
//						databind.disableInput($("#clientManage_details .gradeInfo"));
					} else {
						$("#clientManage_details .gradeInfo .addfile").show();
						$("#clientManage_details .gradeInfo .removeFile").show();
						$("#clientManage_details .saveGrade").show();
						$("#clientManage_details .addBulkstockPledge").show();
						$("#clientManage_details .delete").show();
						databind.enableInput($("#clientManage_details .gradeInfo"));
					}
					
					if ($("#clientManage_details input[name=auditSubmitState4]") == "true") {
						$("#clientManage_details .removeFile").remove();
						$("#clientManage_details .addfile").remove();
					}
					
					//调整资信等级
					$("#clientManage_details .adjustGrade").on("click", function() {
						inquireExistEnterpriseGradeEvaluation(enterpriseId, data);
					});
			
					//调整记录
					$(".adjustGradeRecord").on("click", function() {
						router.route("client/adjustGradeRecord.html?enterpriseId=" + enterpriseId);
					});
					
					tools.inquireCurrentOperationList($("#clientManage_details"));
					
					$(".deleteCommissionScale").unbind("click").click(function(){
						var $this = $(this);
						var jj = layer.confirm('是否确认删除？', {
						  btn: ['确定','取消'] //按钮
						}, function(){
						   deleteCommissionScaleTable($this.parents("tr").attr("scaleId"));
						}, function(){
							layer.close(jj);
						});
					});
					
					$(".disableEnable").unbind("click").click(function(){
						enableCommissionScaleTable($(this).parents("tr").attr("scaleId"));
					});
					
					
					if ($("#clientManage_details input[name=auditSubmitState1]").val() != "true") {
						$("#clientManage_details .multistageAudit7 .button-submit").remove();
						$("#clientManage_details .multistageAudit8 .button-submit").remove();
						$("#clientManage_details .multistageAudit2 .button-submit").remove();
						$("#clientManage_details .multistageAudit9 .button-submit").remove();
						$("#clientManage_details .multistageAudit10 .button-submit").remove();
						$("#clientManage_details .multistageAudit3 .button-submit").remove();
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
					if ($("#clientManage_details input[name=auditSubmitState7]").val() != "true") {
						$("#clientManage_details .multistageAudit8 .button-submit").remove();
						$("#clientManage_details .multistageAudit2 .button-submit").remove();
						$("#clientManage_details .multistageAudit9 .button-submit").remove();
						$("#clientManage_details .multistageAudit10 .button-submit").remove();
						$("#clientManage_details .multistageAudit3 .button-submit").remove();
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
//					if ($("#clientManage_details input[name=auditSubmitState8]").val() != "true") {
//						$("#clientManage_details .multistageAudit2 .button-submit").remove();
//						$("#clientManage_details .multistageAudit9 .button-submit").remove();
//						$("#clientManage_details .multistageAudit10 .button-submit").remove();
//						$("#clientManage_details .multistageAudit3 .button-submit").remove();
//						$("#clientManage_details .multistageAudit4 .button-submit").remove();
//						$("#clientManage_details .multistageAudit5 .button-submit").remove();
//						$("#clientManage_details .multistageAudit6 .button-submit").remove();
//						$("#clientManage_details .multistageAudit11 .button-submit").remove();
//					}
					
					if ($("#clientManage_details input[name=auditSubmitState2]").val() != "true") {
						$("#clientManage_details .saveGrade").addClass("permissionLink");
						tools.inquireCurrentOperationList($("#clientManage_details"));
//						databind.enableInput($("#clientManage_details"));
						$("#clientManage_details .multistageAudit9 .button-submit").remove();
						$("#clientManage_details .multistageAudit10 .button-submit").remove();
						$("#clientManage_details .multistageAudit3 .button-submit").remove();
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
					if ($("#clientManage_details input[name=auditSubmitState9]").val() != "true") {
						$("#clientManage_details .multistageAudit10 .button-submit").remove();
						$("#clientManage_details .multistageAudit3 .button-submit").remove();
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
					if ($("#clientManage_details input[name=auditSubmitState10]").val() != "true") {
						$("#clientManage_details .multistageAudit3 .button-submit").remove();
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
					if ($("#clientManage_details input[name=auditSubmitState3]").val() != "true") {
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
						$("#clientManage_details .multistageAudit12 .button-submit").remove();
					}
					
					if ($("#clientManage_details input[name=auditSubmitState3]").val() != "true") {
						$("#clientManage_details .multistageAudit4 .button-submit").remove();
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
					if ($("#clientManage_details input[name=auditSubmitState4]").val() != "true") {
						$("#clientManage_details .multistageAudit5 .button-submit").remove();
						$("#clientManage_details .multistageAudit6 .button-submit").remove();
						$("#clientManage_details .multistageAudit11 .button-submit").remove();
					}
					
					$.each($(".multistageAudit .submitState"), function() {
						var $this = $(this);
						if ($this.val() == 'true') {
							$this.parent().find(".button-submit").hide();
						}
					});
					
					if (data.datas[0].auditState == 2 || data.datas[0].auditState == 4) {
						$("#clientManage_details .multistageAudit1 .button-submit").remove();
						$("#clientManage_details .multistageAudit7 .button-submit").remove();
						$("#clientManage_details .multistageAudit8 .button-submit").remove();
						$("#clientManage_details .multistageAudit2 .button-submit").remove();
						$("#clientManage_details .multistageAudit9 .button-submit").remove();
						$("#clientManage_details .multistageAudit10 .button-submit").remove();
						$("#clientManage_details .multistageAudit13 .button-submit").remove();
					}
					
					$("#businessLicence").after('&nbsp;&nbsp;&nbsp;&nbsp;<a class="hoverLink" href="/finance/api/v1.0/downloadFile.file?fileUuid='+data.datas[0].certificateImage+'" target="_blank">组织机构代码证</a>');
					$("#businessScope").after('&nbsp;&nbsp;&nbsp;&nbsp;<a class="hoverLink" href="/finance/api/v1.0/downloadFile.file?fileUuid='+data.datas[0].businessLicenceImage+'" target="_blank">营业执照</a>');
					$("#legalIdcard").after('&nbsp;&nbsp;&nbsp;&nbsp;<a class="hoverLink" href="/finance/api/v1.0/downloadFile.file?fileUuid='+data.datas[0].legalPersonFrontImage+'" target="_blank">身份证正面照</a>');
					$("#legalPeriod").after('&nbsp;&nbsp;&nbsp;&nbsp;<a class="hoverLink" href="/finance/api/v1.0/downloadFile.file?fileUuid='+data.datas[0].legalPersonBackImage+'" target="_blank">身份证反面照</a>');
					
					var ii;
					$(".hoverLink").hover(function(){
						var $this = $(this);
						ii = layer.open({
					      title: $this.html(),
					      closeBtn: 0,
					      shadeClose: true,
						  type: 1,
						  maxmin: true,
						  resize: true,
						  skin: 'layui-layer-rim', //加上边框
						  area: 'auto', //宽高
						  maxWidth: '800px',
//						  offset: '100px',
						  content: '<img src="'+$this.attr("href")+'" />'
						});
					}, function(){
					});
				} else {
					base.alert(2, data.message);
				}
			}
		});
	};
	
	return {
		init: init
	};
});